#ifndef LDC1314_H
#define LDC1314_H

#include "stdint.h"

// LDC COMMANDS
#define LDC1314_CMD_DATA_MSB_CH0        0x00
#define LDC1314_CMD_DATA_LSB_CH0        0x01
#define LDC1314_CMD_DATA_MSB_CH1        0x02
#define LDC1314_CMD_DATA_LSB_CH1        0x03
#define LDC1314_CMD_DATA_MSB_CH2        0x04
#define LDC1314_CMD_DATA_LSB_CH2        0x05
#define LDC1314_CMD_DATA_MSB_CH3        0x06
#define LDC1314_CMD_DATA_LSB_CH3        0x07
#define LDC1314_CMD_RCOUNT_CH0          0x08
#define LDC1314_CMD_RCOUNT_CH1          0x09
#define LDC1314_CMD_RCOUNT_CH2          0x0A
#define LDC1314_CMD_RCOUNT_CH3          0x0B
#define LDC1314_CMD_OFFSET_CH0          0x0C
#define LDC1314_CMD_OFFSET_CH1          0x0D
#define LDC1314_CMD_OFFSET_CH2          0x0E
#define LDC1314_CMD_OFFSET_CH3          0x0F
#define LDC1314_CMD_SETTLECOUNT_CH0     0x10
#define LDC1314_CMD_SETTLECOUNT_CH1     0x11
#define LDC1314_CMD_SETTLECOUNT_CH2     0x12
#define LDC1314_CMD_SETTLECOUNT_CH3     0x13
#define LDC1314_CMD_CLOCK_DIVIDERS_CH0  0x14
#define LDC1314_CMD_CLOCK_DIVIDERS_CH1  0x15
#define LDC1314_CMD_CLOCK_DIVIDERS_CH2  0x16
#define LDC1314_CMD_CLOCK_DIVIDERS_CH3  0x17
#define LDC1314_CMD_STATUS              0x18
#define LDC1314_CMD_ERROR_CONFIG        0x19
#define LDC1314_CMD_CONFIG              0x1A
#define LDC1314_CMD_MUX_CONFIG          0x1B
#define LDC1314_CMD_RESET_DEVICE        0x1C
#define LDC1314_CMD_SYSTEM_CLOCK_CONFIG 0x1D
#define LDC1314_CMD_DRIVE_CURRENT_CH0   0x1E
#define LDC1314_CMD_DRIVE_CURRENT_CH1   0x1F
#define LDC1314_CMD_DRIVE_CURRENT_CH2   0x20
#define LDC1314_CMD_DRIVE_CURRENT_CH3   0x21
#define LDC1314_CMD_MANUFACTID          0x7E
#define LDC1314_CMD_DEVID               0x7F



typedef struct Ldc1314
{
    uint16_t    fac_line;
    uint16_t    fac_coin;
    uint16_t    data_ch[4];
    uint16_t    data_base[4];
    int16_t     data_offset[4];
    uint16_t    error;
    uint16_t    state;

    void        (*init)(void);
    void        (*tx)(uint8_t reg_addr, uint16_t data);
    void        (*rx)(uint8_t reg_addr, uint16_t *data);
    void        (*cali)(void);
    void        (*test)(void);
}Ldc1314;

extern Ldc1314 ldc1314;

#endif